package com.gwall.future;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CompletableFuture;

/**
 * @Author lizhilong
 * @create 2019/11/18 18:17
 * @desc supplyAsync 方法有返回值，在get()方法后被触发
 */
@Slf4j
public class SupplyAsync {
    public  static void main(String[] args){
        CompletableFuture<String> future1 = CompletableFuture.supplyAsync(() -> "Hello");

        System.out.println("-------------");

        try {
            String s = future1.get();
            System.out.println(s);
        }catch (Exception e){
            log.info("{}", e.getMessage());
        }
    }
}
